package socketmvc.core.processor.bean.optimizer.ret;

import socketmvc.core.context.IContext;
import socketmvc.core.packets.basic.IPacket;
import socketmvc.core.processor.bean.ProcessorMethodReturn;

public class DefRetPacketValOptimizer extends ProcessorMethodReturn.ValOptimizer {
    @Override
    public IPacket value(IContext context, IPacket packet, Object returnVal) {
        if (returnVal == null){
            return null;
        }
        IPacket returnPacket = (IPacket) returnVal;
        returnPacket.setResponseKey(packet.getResponseKey());
        returnPacket.setResponsePkt(true);
        return returnPacket;
    }
}
